<template>
    <view>
        <view>邀请人：</view>
        <view>成员：</view>
        <view class="bottom" @click="accept" v-if="book">
            <view class="btn">接受</view>
        </view>
    </view>
</template>

<script>
import { mapState } from 'vuex'
import { httpPOST } from '@/common/req'
export default {
  name: 'share',
  data() {
    return {
      bId: '',
      book: null
    }
  },
  onLoad(e) {
    this.bId = e.id
  },
  computed: {
    ...mapState(['userInfo'])
  },
  methods: {
    async getShareBook() {
      const url = 'book/share/get'
      const [err, res] = await httpPOST({ url, param: { id: this.bId } })
      if (res) {
        this.book = res.data
      }
    },
    async accept() {
      const url = 'book/share/accept'
      const u_id = this.userInfo.id
      const [err, res] = await httpPOST({ url, param: { id: this.bId, u_id } })
      if (res) {
        uni.navigateTo({ url: '/main/book/book' })
      }
    }
  }
}
</script>

<style scoped>

</style>
